package com.peach.service.UserManage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;
@Service("RedisApplication")
public class RedisApplicationImpl implements RedisApplication {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @Autowired
    private RedisTemplate<Object,Object> redisTemplate;

    public void set(String key, String value) {
        redisTemplate.opsForValue().set(key, value);
    }

    public String get(String key) {
        return (String) redisTemplate.boundValueOps(key).get();
    }

    public void setCode(String key, String code) {
        stringRedisTemplate.opsForValue().set(key, code, 600, TimeUnit.SECONDS);
    }

    public String getCode(String key) {
        return stringRedisTemplate.boundValueOps(key).get();
    }
}
